<?php

/*
Zoo Management Simulation
This file adds entry information from addCageEntry.php
*/

include("dbconnect.php");
if ($_REQUEST['submit'] == "Return to Administator page"){
	header('Location: setupAdmin.php');
}

$numEntries = $_REQUEST['numentry'];
$entrynumber = 1;
$enclosureid = $_REQUEST['enclosureid'];

$idSql = "(SELECT max(entryid)+1 FROM entry)";
foreach ($dbh->query($idSql) as $row)
	{
		$id = $row[0];
	}

while ($entrynumber <= $numEntries)
	{
		$doortype = $_REQUEST["doortype".$entrynumber];
		$doorstatus = $_REQUEST["doorstatus".$entrynumber];
		$entrysql = "INSERT INTO `entry`(`entryid`, `enclosureid`, `entryTypeId`, `isEntryOpen`) VALUES (".$id.",".$enclosureid.",".$doortype.",".$doorstatus.")";
		$dbh->exec($entrysql);
		$id+=1;
		$entrynumber+=1;
	}
$dbh = null;
header('Location: index.php');

?>